package com.wms.system.domain.Base;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.wms.common.annotation.Excel;
import com.wms.common.core.domain.entity.SysUser;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

@Data
@ApiModel(value = "BasePO", description = "基础表实体")
public class BasePO  implements Serializable {

    /**
     * 用户ID
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @Excel(name = "序号", type = Excel.Type.EXPORT, cellType = Excel.ColumnType.NUMERIC, prompt = "库存绑定id")
    @TableId(type = IdType.AUTO)
    private Long id;

    @Excel(name = "版本号", type = Excel.Type.EXPORT, cellType = Excel.ColumnType.NUMERIC, prompt = "版本号")
    @ApiModelProperty("版本号")
    @TableField("version")
    private Integer version = 0;

    @Excel(name = "是否有效: 0-无效 1-有效", type = Excel.Type.EXPORT, cellType = Excel.ColumnType.NUMERIC, prompt = "是否有效: 0-无效 1-有效")
    @TableField("is_delete")
    private Integer isDelete = 1;

    @TableField("create_by")
    private Long createBy;

    @TableField("update_by")
    private Long updateBy;

    @TableField("create_user_name")
    @ApiModelProperty("创建人名称")
    @Excel(name = "创建人名称", type = Excel.Type.EXPORT, cellType = Excel.ColumnType.STRING, prompt = "创建人名称")
    private String createUserName;

    @TableField("create_time")
    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "创建时间", type = Excel.Type.EXPORT, cellType = Excel.ColumnType.TEXT, prompt = "创建时间")
    private Date createTime;



    @ApiModelProperty("修改人名称")
    @TableField("update_user_name")
    @Excel(name = "修改人名称", type = Excel.Type.EXPORT, cellType = Excel.ColumnType.TEXT, prompt = "修改人名称")
    private String updateUserName;

    @TableField("update_time")
    @ApiModelProperty("修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "修改时间", type = Excel.Type.EXPORT, cellType = Excel.ColumnType.TEXT, prompt = "修改时间")
    private Date updateTime;

    @TableField("remark")
    @ApiModelProperty("备注")
    @Excel(name = "备注", type = Excel.Type.EXPORT, cellType = Excel.ColumnType.TEXT, prompt = "备注")
    private String remark;

    public void setUserAndTime(SysUser user, Date date) {
        this.createBy = user.getUserId();
        this.createTime = date;
        this.createUserName = user.getUserName();
        this.updateBy = user.getUserId();
        this.updateTime = date;
        this.updateUserName = user.getUserName();
    }

}
